package cn.wolfcode.java39.rocketmqconsumerdemo.api._02_producer_type;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;

//不可靠,用在日志
public class OneWayProducer {
    public static void main(String[] args) throws Exception {
        //创建一个生产者对象
        DefaultMQProducer producer = new DefaultMQProducer("wolfcode-producer");
        //设置nameserver地址
        producer.setNamesrvAddr("192.168.136.128:9876;192.168.136.129:9876");
        //启动生产者
        producer.start();
        //创建100个message对象
        for (int i=0; i < 100; i++){
            Message message = new Message("02-producer_type", "hello,rocketmq".getBytes("utf-8"));
            ///一次性消费
            producer.sendOneway(message);


        }
        //关闭生产者
        producer.shutdown();
    }
}
